#include<iostream>
#include<fstream>
#include <time.h>
#include <map>
using namespace std;
int main(){
    clock_t start,end;
    map <int, int> numbers; //this can be "map <int,char>" if we are sure a number will not exist more than 256 times
    ifstream fin("unsorted.txt");
    ofstream fout("sorted.txt");
    
    start=clock(); // to calculate the speed
    
    int temp;
    
    while(fin>>temp){ 
                      numbers[temp]++; //read from the file
                      
                      }

    for(int k=0 ; k<numbers.size() ; k++)
            for(int i=0 ; i<numbers[k] ; i++)
                    fout<<k<<endl; // write the result into the file
                    
                    
    end=clock();//finished 
    
    cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl; //show how long it took
    
    return 0;
}
